how to program shortest path finder